Back to course home
0% completed
Vote For New Content
Amazon Hard Problems
Constrained Subsequence Sum (hard)
Solution: Constrained Subsequence Sum
Number of Valid Subarrays (hard)
Solution: Number of Valid Subarrays
Count Vowels Permutation (hard)
Solution: Count Vowels Permutation
Concatenated Words (hard)
Solution: Concatenated Words
Minimum Replacements to Sort the Array (hard)
Solution: Minimum Replacements to Sort the Array
Count All Valid Pickup and Delivery Options (hard)
Solution: Count All Valid Pickup and Delivery Options
Length of the Longest Valid Substring (hard)
Solution: Length of the Longest Valid Substring
Count Array Pairs Divisible by K (hard)
Solution: Count Array Pairs Divisible by K
Word Ladder (hard)
Solution: Word Ladder
Path with Maximum Sum (hard)
Solution: Path with Maximum Sum
Coin Change II (medium)
Problem Statement
Given an integer array coins, where coins[i] = x represents the coin of amount x, and integer amount, return the total number of distinct ways to make a amount of money using a given set of coin denominations. If that amount of money cannot be made up by any combination of the coins, return 0.
You can have an infinite number of each coin.
Examples
-
Example 1:
- Input:
amount = 4, coins = [1,2,3] - Expected Output:
4 - Justification: The four ways to make 4 are:
[1,1,1,1],[1,1,2],[2,2], and[1,3].
- Input:
-
Example 2:
- Input:
amount = 10, coins = [2, 5, 3, 6] - Expected Output:
5 - Justification: The five ways to make 10 are:
[2,2,2,2,2],[2,2,3,3],[5,5],[2,2,6], and[2,3,5]`.
- Input:
-
Example 3:
- Input:
amount = 0, coins = [7,3] - Expected Output:
1 - Justification: There is only one way to make 0, which is by not using any coins at all.
- Input:
Try it yourself
Try solving this question here:
Java
. . . .
Solution: The kth Factor of n
Solution: Coin Change II
Mark as Completed
On this page
Problem Statement
Examples
Try it yourself